"""
File: wework.py
Author: ershixiong
Date: 2023/12/12
describe:

"""
import json
import os

import requests

from project202311_wework.wework.frame.apis.base_api import BaseApi
from project202311_wework.wework.frame.utils.log_utils import logger
from project202311_wework.wework.frame.utils.utils import Utils


class Wework(BaseApi):
    def __init__(self, corpid, corpsecret):
        # self.access_token = self.get_access_token()
        self.base_url = 'https://qyapi.weixin.qq.com/cgi-bin/'
        self.access_token = self.get_access_token(corpid, corpsecret)

    def get_access_token(self, corpid, corpsecret):
        url = f'{self.base_url}gettoken'
        params = {
            'corpid': corpid,
            'corpsecret': corpsecret
        }
        r = requests.get(url, params=params)
        self.access_token = r.json()['access_token']
        return self.access_token

